<template>
  <div>
    <h2>产品类别</h2>
    <div class="chart" id="mychartsFour">图表容器4</div>
  </div>
</template>

<script>
import { inject, onMounted, reactive } from "vue";
export default {
  setup() {
    let $echarts = inject("echarts");
    let $http = inject("axios");

    let data = reactive({});

    async function getState() {
      data = await $http({ url: "/four/data" });
    }
    onMounted(() => {
      getState().then(() => {
        let myChart = $echarts.init(document.getElementById("mychartsFour"));
        myChart.setOption({
          xAxis: {
            type: "category",
            boundaryGap: false, //清除间隙
            data: data.data.chartData.chartData.day,
            axisLine: {
              lineStyle: {
                color: "#fff",
              },
            },
          },
          yAxis: {
            type: "value",
            axisLine: {
              lineStyle: {
                color: "#fff",
              },
            },
          },
          legend: {},
          grid: {
            left: "1%",
            containLabel: true,
          },
          tooltip: {
            trigger: "axis",
            axisPoint: {
              type: "shadow",
            },
          },
          series: [
            {
              name: "服饰",
              type: "bar",
              stack: "total",
              label: {
                show: true,
              },
              emphasis: {
                focus: "series",
              },
              data: data.data.chartData.chartData.num.Chemicals,
            },
            {
              name: "数码",
              type: "bar",
              stack: "total",
              label: {
                show: true,
              },
              emphasis: {
                focus: "series",
              },
              data: data.data.chartData.chartData.num.Clothes,
            },
            {
              name: "家电",
              type: "bar",
              stack: "total",
              label: {
                show: true,
              },
              emphasis: {
                focus: "series",
              },
              data: data.data.chartData.chartData.num.Eletrical,
            },
            {
              name: "家具",
              type: "bar",
              stack: "total",
              label: {
                show: true,
              },
              emphasis: {
                focus: "series",
              },
              data: data.data.chartData.chartData.num.digit,
            },
            {
              name: "日化",
              type: "bar",
              stack: "total",
              label: {
                show: true,
              },
              emphasis: {
                focus: "series",
              },
              data: data.data.chartData.chartData.num.gear,
            },
          ],
        });
      });
    });
  },
};
</script>

<style></style>
